const express = require('express');
const ejs = require('ejs'); // 模版引擎
const app = express();
const path = require('path')

const UserRouter = require('./router/user')
const ListRouter = require('./router/list')

// ejs
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'html')
app.engine('html', ejs.renderFile)

// post参数
app.use(express.json())
app.use(express.urlencoded({
  extended: false
}))

// 静态资源   js(axios.js  /img /js/ ) css img  (html)
app.use(express.static('./public'))

app.use('/', UserRouter)
app.use('/api', ListRouter)

app.listen(8888, () => {
  console.log('server port is 8888')
})
